import axios from "axios"

const instance = axios.create({
    baseURL: "http://192.168.113.249:8081/cms"
})

instance.interceptors.request.use(config => {
    let token = sessionStorage.getItem("x-auth-token")
    if (token) {
        config.headers["x-auth-token"] = token
    }
    console.log("请求拦截器....");
    return config
}), error => {
    return Promise.reject(error)
}
instance.interceptors.response.use(res => {

    console.log("响应拦截器....", res);
    if (res.data.code != 0 && res.data.code != 400 && res.data.code != 407) {
        alert(res.data.message)
        return
    }
    return res.data

}), error => {
    return Promise.reject(error)

}
export default instance